package com.lly;


import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;

@WebServlet("/servletB")
public class ServletB extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取请求域的数据
        String reqyu = (String) req.getAttribute("reqyu");
        System.out.println(reqyu);

        //获取会话域的数据
        HttpSession session = req.getSession();;
        String session1 = (String) session.getAttribute("session");
        System.out.println(session1);

        //获取应用域
        ServletContext servletContext = getServletContext();
        String application = (String) servletContext.getAttribute("application");
        System.out.println(application);
    }
}
